//--------------------------------------------------------------------------
// File and Version Information:
// 	$Id: HepRepXMLWriter.cc,v 1.5 2002/02/05 12:04:25 perl Exp $
//
// Description:
//	Example of how to use HepRepXMLWriter,
//      a Utility for the creation of HepRep XML Files (HepRep version 1).
//      Draws a few simple lines, cylinders and prisms
//      including some Type, SubType structure.
//
//      For details, see:
//      http://www.slac.stanford.edu/~perl/HepRepXMLWriter.html
//
// Environment:
//	Software developed for the general High Energy Physics community.
//
// Author :
//      Joseph Perl                 Original Author
//
// Copyright Information:
//      Copyright (C) 2002          Stanford Linear Accelerator Center
//------------------------------------------------------------------------
#include "HepRepXMLWriter.hh"

void main() {
  HepRepXMLWriter* writer = new HepRepXMLWriter();
  writer->open("ExampleOutput.heprep");
  writer->addAttDef("Pole","North or South Pole","Physics","");

  // Center Line.
  writer->addType("Center Line",0);
  writer->addAttValue("DrawAs","Line");
  writer->addAttValue("LineColor",1.,1.,0.);
  writer->addAttValue("LineWidth",4.);
  writer->addInstance();
  writer->addPrimitive();
  // Endpoints of Line.
  writer->addPoint(0.,0.,-100);
  writer->addPoint(0.,0.,100.);

  // Cylinders.
  writer->addType("Outer Cylinders",0);
  writer->addAttValue("DrawAs","Cylinder");
  writer->addAttValue("Radius1","30.");
  writer->addAttValue("Radius2","30.");
  writer->addAttValue("LineColor",1.,1.,0.);
  writer->addInstance();
  writer->addAttValue("Pole","South");
  writer->addPrimitive();
  // Center Points of Cylinder Ends.
  writer->addPoint(0.,0.,-50.);
  writer->addPoint(0.,0.,-45.);
  writer->addInstance();
  writer->addAttValue("Pole","North");
  writer->addPrimitive();
  // Center Points of Cylinder Ends.
  writer->addPoint(0.,0.,45.);
  writer->addPoint(0.,0.,50.);

  // Prism.
  writer->addType("Prism and Inner Cylinders",0);
  writer->addInstance();
  writer->addAttValue("DrawAs","Prism");
  writer->addAttValue("LineColor",1.,0.,1.);
  writer->addPrimitive();
  // -Z face of prism.
  writer->addPoint(20.,20.,-40.);
  writer->addPoint(20.,-20.,-40.);
  writer->addPoint(-20.,-20.,-40.);
  writer->addPoint(-20.,20.,-40.);
  // +Z face of prism.
  writer->addPoint(20.,20.,40.);
  writer->addPoint(20.,-20.,40.);
  writer->addPoint(-20.,-20.,40.);
  writer->addPoint(-20.,20.,40.);

  // Cylinder, placed at level 2 making it substructure of the Prism.
  writer->addType("Inner Cylinders",1);
  writer->addAttValue("DrawAs","Cylinder");
  writer->addAttValue("LineColor",0.,1.,1.);
  writer->addAttValue("Radius1","15.");
  writer->addAttValue("Radius2","15.");
  writer->addInstance();
  writer->addAttValue("Pole","South");
  writer->addPrimitive();
  // Center Points of Cylinder Ends.
  writer->addPoint(0.,0.,-30.);
  writer->addPoint(0.,0.,-2.);
  writer->addInstance();
  writer->addAttValue("Pole","North");
  writer->addPrimitive();
  // Center Points of Cylinder Ends.
  writer->addPoint(0.,0.,2.);
  writer->addPoint(0.,0.,30.);

  writer->close();
};

